home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / GUSI 1.4.1 / GUSI / Examples / GUSITest_P.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-25  |  911 b   |  32 lines  |  [TEXT/MPS ]

  1. /*********************************************************************
  2. File        :    GUSI                -    Grand Unified Socket Interface
  3. File        :    GUSITest_P.h    -    Common testing gear
  4. Author    :    Matthias Neeracher <neeri@iis.ethz.ch>
  5. Language    :    MPW C
  6.  
  7. $Log: GUSITest_P.h,v $
  8. Revision 1.1  1994/02/25  02:48:27  neeri
  9. Initial revision
  10.  
  11. *********************************************************************/
  12.  
  13. #include <CType.h>
  14.  
  15. #define NROFCHARS                26
  16. #define DECODE(ch)            ((ch) ? (ch) - (isupper(ch) ? 'A' : 'a') + 1 : 0)
  17. #define CMDCODE(ch1,ch2)    (DECODE(ch1)*(NROFCHARS+1)+DECODE(ch2))
  18. #define NROFCMDS                (NROFCHARS+1)*(NROFCHARS+1)
  19.  
  20. typedef struct {
  21.     TestCmd            proc;
  22.     const char *    syntax;
  23.     const char *    help;
  24. } CmdDef;
  25.  
  26. extern CmdDef commands[NROFCMDS];
  27.  
  28. #define DISPATCH(ch1,ch2)    commands[CMDCODE(ch1,ch2)].proc
  29. #define USAGE(ch1,ch2)         commands[CMDCODE(ch1,ch2)].syntax
  30. #define HELPMSG(ch1,ch2)     commands[CMDCODE(ch1,ch2)].help
  31.  
  32.